#include <QHBoxLayout>
#include <QLabel>
#include <QToolButton>
#include "navigator-bar-element.h"

NavigatorBarElement::NavigatorBarElement (const QString& buttonText, const QString& labelText, int number, QWidget* parent)
    : QWidget(parent), m_button(new QToolButton(this)), m_label(new QLabel(labelText, this)),
      m_orderNumber(number)
{
    m_button->setText(buttonText);
    m_button->setAutoRaise(true);
    m_layout = new QHBoxLayout(this);
    m_layout->addWidget(m_button);
    m_layout->addWidget(m_label);
    m_layout->setContentsMargins(0, 0, 0, 0);
    m_layout->setSpacing(1);
    connect (m_button, &QToolButton::clicked, this, &NavigatorBarElement::buttonClicked);
}

void NavigatorBarElement::buttonClicked()
{
    emit activated(orderNumber());
}

void NavigatorBarElement::setAsCurrent (bool current)
{
    QFont font = m_button->font();
    font.setBold(current);
    m_button->setFont(font);
}
